package cn.lanqiao.bigDate.api.config;

import cn.lanqiao.bigDate.api.config.interceptor.WebInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Marisa
 * @description 描述
 * @date 2022/4/21
 */
@Configuration
public class frontEndWebConfig implements WebMvcConfigurer {

    @Bean
    public WebInterceptor getWebInterceptor(){
        return new WebInterceptor();
    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedMethods("*")
                .allowedOrigins("*")
                ;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] exclude = {"/**/faceLogin", "/**/faceCreate","/**/test"};
        registry
        .addInterceptor(getWebInterceptor())
        .addPathPatterns("/**")
        .excludePathPatterns(exclude)
        ;
    }
}
